In a known form of digital data processing using a pipelined processor, a succession of instructions are processed simultaneously, each being executed in part at a succession of stages. Each instruction generally consists of an opcode or control field which specifies the operation to be carried out. Certain instructions also have literal fields.
A literal is a specific number, whether large or small, which is associated with an instruction and is used in performing the function directed by that instruction. A literal is a constant, in contra-distinction to a variable. It is used, for instance, to represent an index amount for an address calculation, a branch amount to be added to the program counter value, a shift amount for SHIFT AND ROTATE instructions, or floating point numbers in ADD FLOATING WITH IMMEDIATE DATA instructions.
Where a literal is contained in the instruction with which it is to be used, and is available immediately for use without further modification or processing, the literal is called an "immediate" or direct literal.
The size requirement, in bits, of a direct literal which must be accommodated in the literal field of the instruction varies greatly. For instance, a shift instruction might need a maximum of five bits to specify a shift amount while a floating point instruction might require a 32-bit value. In the past, instructions were formatted to have differing lengths to account for this bit-size difference. Accommodating such variations in instruction length, however, typically required more complicated processor design, and slower processing times due to the more complex control logic.
To avoid the disadvantages arising from processing variable-length instructions, solutions have been proposed for handling different length literals in a fixed-length-instruction format. These can be more readily described, and their shortcomings pointed out, with resort to an illustrative example, in which an instruction set is made up of fixed-length, 32-bit instructions that need to specify literals of five to 32 bits in length.
A first way to generate literals of such diverse lengths is to use two instructions, each containing, in addition to an opcode in its control field, part of the literal in its literal field--e.g., one that directs the loading of the upper 16-bits of the literal from its 16-bit literal field and the other that directs the loading of the lower 16-bits of the literal from its 16-bit literal field. A disadvantage with this approach is that, if the size of the literal is not known at compile time, then the compiler must assume that the number is a 32-bit value in order to be sure to compile the entire literal, regardless of whether it actually has a smaller bit value. Later, when the true length of the literal is known, most commonly at link time, the linker replaces the tag with the actual number. Unfortunately, in those cases in which the literals are of shorter lengths, e.g., five or six bits, such as typically would be the case for literals used in designating jumps between separately compiled code segments, the compiler need only have compiled the five or six bits instead of the 32-bits it actually compiled. Furthermore, the use of a second instruction to carry the literal was superfluous. Clearly, this approach is inefficient and wasteful of computer resources.
A second method of providing large literals, this time using a single fixed-length instruction, is to have the instruction specify an address in memory containing the literal. The literal is indirectly specified and, therefore, can be termed an "indirect literal." In other words, for indirect literals, the literal field contains a memory address and the desired literal is fetched, using that address, from a library of literals stored in memory. This permits the folding of literals in the library in order to save memory space, but is costly in terms of execution time.
Desirable is an efficient technique for providing both large and small literals using fixed-length instructions. Such a technique preferably would realize the advantages in execution time and overhead achieved by direct literals for expressing numbers having shorter bit-values, and also realize the greater capability and versatility achieved by indirect literals, particularly for expressing numbers of larger bit-values.